﻿using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using Newtonsoft.Json;

namespace AgileNYCWebService
{
	internal class JsonHelper
	{
		/// <summary>
		/// JSON Serialization
		/// </summary>
		public static string JsonSerializer<T>(T t)
		{
			var jsonSerializerSettings = new JsonSerializerSettings();
			jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore;
			jsonSerializerSettings.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
			return JsonConvert.SerializeObject(t, jsonSerializerSettings);
		}

		/// <summary>
		/// JSON Deserialization
		/// </summary>
		public static T JsonDeserialize<T>(string jsonString)
		{
			return (T)JsonConvert.DeserializeObject(jsonString);
		}
	}
}